package com.wizz.trade.common;

import com.wizz.trade.util.MyStringUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;

/**
 * @author fyftless
 * 分页参数基本封装
 */
@Data
public class PageDto implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "页号")
    private Integer pageNumber = 1;

    @ApiModelProperty(value = "页面大小")
    private Integer pageSize = 10;

    @ApiModelProperty(value = "排序字段")
    private String sort;

    @ApiModelProperty(value = "排序方式 asc/desc")
    private String order;

    public String getRealSort(){
        if(!StringUtils.isEmpty(sort)){
            return MyStringUtils.camel2Underline(sort);
        }
        return sort;
    }
}
